package com.itheima.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionDemo2 {
    public static void main(String[] args) {
        Collection<String> coll = new ArrayList<>();
        coll.add("a");
        coll.add("b");
        coll.add("b");
        coll.add("c");
        coll.add("d");

        Iterator<String> it = coll.iterator();

        while(it.hasNext()){
            String s = it.next();
            System.out.print(s+" ");
        }

        System.out.println();

        it = coll.iterator();
        while(it.hasNext()){
            String s = it.next();
            if("b".equals(s)){
                it.remove();
            }
        }
        System.out.println(coll);
    }
}
